home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 9DM0UF (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.6 KB  |  40 lines

  1. package com.sun.java.swing.tree;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.Stack;
  5. import java.util.Vector;
  6.  
  7. final class DefaultMutableTreeNode$PreorderEnumeration implements Enumeration {
  8.    // $FF: synthetic field
  9.    DefaultMutableTreeNode this$0;
  10.    protected Stack stack;
  11.  
  12.    // $FF: synthetic method
  13.    public DefaultMutableTreeNode$PreorderEnumeration(DefaultMutableTreeNode this$0, TreeNode rootNode) {
  14.       this.this$0 = this$0;
  15.       Vector v = new Vector(1);
  16.       v.addElement(rootNode);
  17.       this.stack = new Stack();
  18.       this.stack.push(v.elements());
  19.    }
  20.  
  21.    public boolean hasMoreElements() {
  22.       return !this.stack.empty() && ((Enumeration)this.stack.peek()).hasMoreElements();
  23.    }
  24.  
  25.    public Object nextElement() {
  26.       Enumeration enumer = (Enumeration)this.stack.peek();
  27.       TreeNode node = (TreeNode)enumer.nextElement();
  28.       Enumeration children = node.children();
  29.       if (!enumer.hasMoreElements()) {
  30.          this.stack.pop();
  31.       }
  32.  
  33.       if (children.hasMoreElements()) {
  34.          this.stack.push(children);
  35.       }
  36.  
  37.       return node;
  38.    }
  39. }
  40.